<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Support\Facades\Hash;

class UserController extends Controller
{
    //
    public function index()
    {
        $data  = User::withTrashed()->get();
        $assign = compact('data');

        return view('admin.user.index', $assign);
    }
    
 
    public function edit($id)
    {
        $data   = User::withTrashed()->find($id);
         $assign = compact('data');
        return view('admin.user.edit', $assign);
    }
    public function update(Request $request, $id)
    {
    	$data=$request->except('_token','q');
$data['password']=Hash::make($data['password']);
    	User::withTrashed()->find($id)->update($data);

        return redirect()->back();
    }
    public function destroy($id)
    {
        User::destroy($id);

        return redirect(url('admin/user'));
      
    }
    //恢复删除
    public function restore($id)
    {
        User::onlyTrashed()->find($id)->restore();

        return redirect(url('admin/user'));
    }
//彻底删除
    public function forceDelete($id)
    {
        User::onlyTrashed()->find($id)->forceDelete();

        return redirect(url('admin/user'));
    }
    

}
